<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/iconfont.css" rel="stylesheet" />
		<style type="text/css">
			.mui-bar{
				border-top: 2px solid #DEDEDE;
				background-color: #FFFFFF;
			}
		</style>
	</head>
	<body>		 
		<!--底部tabbar-->
		<nav class="mui-bar mui-bar-tab" id="tabbarshow">
			<a class="mui-tab-item mui-active" data-id="dongwall.html">
				<span class="mui-icon iconfont icon-huaban-copy"></span>
				<span class="mui-tab-label">首页</span>
			</a>
			<a class="mui-tab-item" data-id="jianzhi.html">
				<span class="mui-icon iconfont icon-wodejianzhi"></span>
				<span class="mui-tab-label">兼职</span>
			</a>
			<a class="mui-tab-item" data-id="news.html">
				<span class="mui-icon iconfont icon-yuyin"><span class="mui-badge">99+</span></span>
				<span class="mui-tab-label">消息</span>
			</a>
			<a class="mui-tab-item" data-id="goodfrends.html">
				<span class="mui-icon iconfont icon-haoyou"></span>
				<span class="mui-tab-label">好友</span>
			</a>
			<a class="mui-tab-item" data-id="mine.html" id="mine">
				<span class="mui-icon iconfont icon-woh2x"></span>
				<span class="mui-tab-label">我的</span>
			</a>
		</nav>
		
		
		<div class="mui-content">
		    
		</div>
	<script src="../js/mui.min.js"></script>			
    <script src="../js/mui.zoom.js"></script>
	<script src="../js/mui.previewimage.js"></script>
	<script src="../js/mui.pullToRefresh.js"></script>
	<script src="../js/mui.pullToRefresh.material.js"></script>
    <script type="text/javascript">
    	
			mui.init();
			
			document.getElementById('mine').addEventListener('tap',function(){
				//document.getElementById('topbar').style.cssText = "opacity: 1;color: aqua;" 
			})
			
			var h = document.body.scrollHeight;
			window.onresize = function(){
			if (document.body.scrollHeight < h) {
			    document.getElementsByTagName("nav")[0].style.display = "none";
			}else{
			    document.getElementsByTagName("nav")[0].style.display = "block";
			
			}
			}
			
			
			mui.plusReady(function() {
				var a = plus.webview.currentWebview().dongtai;
				var self = null;
			    var activeTab = null; 
			    var subpage_style={top: 0,bottom: '51px'};
				//关闭右滑返回
				plus.webview.currentWebview().setStyle({
					'popGesture': 'none'
				});

				mui.preload({
				      url:'jianzhi.html',
				      id:'jianzhi.html',
				      styles: subpage_style
				})
				mui.preload({
				      url:'news.html',
				      id:'news.html',
				      styles: subpage_style
				})
				mui.preload({
				      url:'goodfrends.html',
				      id:'goodfrends.html',
				      styles: subpage_style
				})
				self = plus.webview.currentWebview();
				var sub = plus.webview.create("dongwall.html", "dongwall.html", subpage_style);
				self.append(sub);
				activeTab = "dongwall.html";
 
				//选择底部菜单
				mui('.mui-bar-tab').on('tap', 'a', function(e) {
					var targetTab = this.getAttribute('data-id');
					//mui.alert(targetTab);
					if(targetTab == activeTab) {
						return;
					}
					var _subWv = plus.webview.getWebviewById(targetTab);
 
					//如果不存在则创建
					if(!_subWv) {
						_subWv = plus.webview.create( targetTab, targetTab, subpage_style);
						self.append(_subWv);
					}
					_subWv.show();
					// 隐藏之前的webview
					plus.webview.getWebviewById(activeTab).hide('none');
					activeTab = targetTab;
				});
				
				mui('.mui-bar').on('tap','.mui-tab-item',function(e){
					plus.navigator.setStatusBarStyle('light');
					if(this.getElementsByTagName("span")[1].textContent == '我的'){
						var perview =  plus.webview.getWebviewById('mine.html');
						mui.fire(perview,'newsId',{});
					}
					if(this.getElementsByTagName("span")[1].textContent != '好友'){
						var perview =  plus.webview.getWebviewById('goodfrends.html');
						mui.fire(perview,'popoverhide',{});
					}
				})
			});
			
		//按两次返回键退出应用
		var first = null;
           mui.back = function(){
                mui.plusReady(function() {
                    //首页返回键处理
                    //处理逻辑：1秒内，连续两次按返回键，则退出应用；
                    if(!first){
                        first = new Date().getTime();
                        mui.toast('再按一次退出应用');
                        setTimeout(function(){
                            first = null;
                        },1000);
                    }else{
                        if(new Date().getTime()-first<1000){
                            plus.runtime.quit();
                        }
                    }
                });
            }
		</script>	
</body>
</html>